home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / rdslik1a / asyncadd.asp next >
Text File  |  1999-07-27  |  2KB  |  53 lines

  1. <!-- #include file="Functions.inc" -->
  2. <%
  3.     response.buffer = false
  4.     NewValue=request.querystring("NewValue")
  5.     TableName=request.querystring("Table")
  6.     FieldNameID=request.querystring("FieldID")
  7.     FieldNameDesc=request.querystring("FieldDesc")
  8.     cmbName=request.querystring("cmbName")
  9.     AllowDup=request.querystring("AllowDup")
  10.     ExtraFields=request.querystring("ExtraFields")
  11.     if (NewValue = "") or (TableName="") or (FieldNameID="") or (FieldNameDesc="") then 
  12.         Response.Write "<script LANGUAGE=""VBSCRIPT"">"&Chr(10)
  13.         response.write "Msgbox ""No Value was entered. Please retry this opperation.""" & chr(10)
  14.         Response.Write "</SCRIPT>" 
  15.         response.end
  16.     end if
  17.     if Not AllowDup then
  18.         strSQL="SELECT * FROM "& TableName &" WHERE "& FieldNameDesc &" = '" & NewValue & "'"
  19.         set Conn=server.createobject("adodb.connection")
  20.  
  21.         '******************************************************************************
  22.         'You can put the Connection parameters into application variables if you want!!
  23.         '******************************************************************************
  24.         '        conn.open Application("DSN"), Application("uid"), Application("pwd")
  25.         conn.open "TESTCOMBO", "Admin", ""
  26.  
  27.         Set Rs = Conn.execute (strSQL)
  28.         if not Rs.eof then
  29.             Response.Write "<script LANGUAGE=""VBSCRIPT"">"&Chr(10)
  30.             response.write "Msgbox ""The Value you entered already excist in the database.""" & chr(10)
  31.             Response.Write "</SCRIPT>" 
  32.             response.end
  33.         end if
  34.         rs.close
  35.         set rs = nothing
  36.         set Conn = nothing
  37.     end if
  38.     NewNum = CreateMaxIDExt(TableName,FieldNameID,FieldNameDesc,"'" & NewValue & "'")
  39.     if NewNum = -1 then 
  40.         Response.Write "<script LANGUAGE=""VBSCRIPT"">"&Chr(10)
  41.         response.write "Msgbox ""Couldn't retrieve a new number. Please retry this opperation.""" & chr(10)
  42.         Response.Write "</SCRIPT>" 
  43.         response.end
  44.     end if
  45.  
  46.     Response.Write "<script LANGUAGE=""VBSCRIPT"">"&Chr(10)
  47.     Response.write "    Sub Window_onload()"&chr(10)
  48.     Response.write "        Call Parent.AddToList("""& NewValue &""","& NewNum &",Parent."& cmbName &")"&chr(10)
  49.     Response.write "    End Sub"&Chr(10)&Chr(10)
  50.     Response.Write "</SCRIPT>" 
  51.     Response.end
  52. %>
  53.